package com.lw.demo;

import java.time.Duration;
import java.time.Instant;
import java.util.stream.LongStream;

/**
 * @author LW
 * @2021/9/18 16:29
 */
public class TestForLoop {
    public static void main(String[] args) {
        long[] numbers = LongStream.rangeClosed(1, 1000000000L).toArray();
        Instant start = Instant.now();
        Calculator calculator = new ForLoopCalculator();//for循环计算
        long result = calculator.sumUp(numbers);
        Instant end = Instant.now();
        System.out.println("耗时：" + Duration.between(start, end).toMillis() + "ms");//75ms

        System.out.println("结果为：" + result);
    }
}
